from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status

from users.models import CustomUser


class PersonnelDistributionView(APIView):
    def get(self, request):
        artist_count = CustomUser.objects.filter(role=CustomUser.ARTIST, is_staff=0).count()
        buyer_count = CustomUser.objects.filter(role=CustomUser.BUYER, is_staff=0).count()
        personne_count = CustomUser.objects.filter().count()
        response_data = {
            'artist_count': artist_count,
            'buyer_count': buyer_count,
            'personne_count': personne_count - 1,  # exclude admin
        }
        return Response(data={'data': response_data}, status=status.HTTP_200_OK)
